//数组去重
function removalTwo(a, b) {
    return Array.from(new Set([...a, ...b]));
}
//数组去重
function removal(a) {
    return Array.from(new Set(a));
}
//数组交叉比较
function crossCompare(oria, newa) {
    let ret = {add:[], dec:[]}
    for (let i = 0; i < newa.length; i++) {
        if (oria.includes(newa[i])===false) {
            ret.add.push(newa[i]);
        }
    }
    for (let i = 0; i < oria.length; i++) {
        if (newa.includes(oria[i])===false) {
            ret.dec.push(oria[i]);
        }
    }
    return ret;
}
//去掉原数组中有,新数组没有的元素
function crossRemove(oria, newa) {
    for (let i = 0; i < oria.length; i++) {
        if (newa.includes(oria[i])===false) {
            oria.splice(i, 1);
            i--;
        }
    }
    return oria;
}
//增加原数组中没有,新数组有的元素
function crossAdd(oria, newa) {
    for (let i = 0; i < newa.length; i++) {
        if (oria.includes(newa[i])===false) {
            oria.push(newa[i]);
        }
    }
    return oria;
}

// let a=[4,6,8,5,49,483,45];
// let b=[4,738,8,763,49];
// console.log(removal([...a, ...b]));
// console.log(removalTwo(a,b));
// console.log(crossCompare(a,b));
// console.log(crossRemove(a,b));

module.exports.removal = removal;
module.exports.removalTwo = removalTwo;
module.exports.crossCompare = crossCompare;
module.exports.crossRemove = crossRemove;
module.exports.crossAdd = crossAdd;